import java.util.*;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-15
 * Time: 9:57
 */
//排序子序列
    //涉及非递增序列和非递减序列
    //非递增序列是该序列递减，但是有重复数字
    //非递增序列是该序列递减，但是有重复数字
public class Main {
    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
        int n=scanner.nextInt();
        int []array=new int[n+1];
        for(int i=0;i<n;i++){
            array[i]=scanner.nextInt();
        }
        int i=0;
        int count=0;
        while(i<n){
            if(array[i]<array[i+1]){
                while( i<n && array[i]<array[i+1]) {
                    i++;
                }
                count++;
                i++;
            }else if(array[i]==array[i+1]){
                i++;
            }else{
                while( i<n &&array[i]>array[i+1]) {
                    i++;
                }
                count++;
                i++;
            }
        }
        System.out.println(count);

    }
}
